<template>
  <div class="category">
    <div class="category-header">
      <el-row :gutter="20">
        <el-col :span="6">
          <el-statistic
            style="margin-top: 42px"
            :value="tableData.length"
            title="类别总数"
          >
            <template slot="suffix">
              <span class="like">
                <i class="el-icon-star-on" style="color: red"></i>
              </span>
            </template>
          </el-statistic>
        </el-col>
        <el-col :span="14">
          <el-card class="box-card">
            <div slot="header" class="clearfix">
              <span>添加分类卡片</span>
              <el-button style="float: right; padding: 3px 0" type="text">
                添加
              </el-button>
            </div>
            <div class="text item">
              <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="分类">
                  <el-input v-model="form.classifyName"></el-input>
                </el-form-item>

                <el-form-item label="备注">
                  <el-input type="textarea" v-model="form.remark"></el-input>
                </el-form-item>
              </el-form>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="分类">
        <el-input v-model="formInline.user" placeholder="分类"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
      </el-form-item>
    </el-form>

    <el-table :data="tableData" border style="width: 100%">
      <el-table-column prop="classifyName" label="分类"> </el-table-column>
      <el-table-column prop="remark" label="备注"> </el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">
            编辑
          </el-button>
          <el-button @click="handleClick(scope.row)" type="text" size="small">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      formInline: {
        user: "",
        region: "",
      },
      tableData: [
        {
          classifyName: "吃饭",
          remark: "",
        },
        {
          classifyName: "交通",
          remark: "",
        },
        {
          classifyName: "购物",
          remark: "",
        },
        {
          classifyName: "衣物",
          remark: "",
        },
      ],

      form: {
        classifyName: "",
        remark: "",
      },
    };
  },

  methods: {
    onSubmit() {
      console.log("submit!");
    },
    handleClick(row) {
      console.log(row);
    },
  },
};
</script>





<style scoped>
.category {
  padding: 20px 40px;
}
.category-header {
  padding: 20px 40px;
}
.el-card.is-always-shadow {
  float: right;
}
.like {
  cursor: pointer;
  font-size: 25px;
  display: inline-block;
}
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}
.el-row {
  padding-bottom: 40px;
  border-bottom: 1px solid #f2eff5;
}
.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  width: 480px;
}
</style>